<?php
require_once 'adminmenu.php';
?>
<div class="well">
    <h4>List of anonces:</h4>
    <hr />
    <table class="table table-striped">
        <thead>
            <tr><th>#</th><th>name</th><th>created/modified</th><th>actions</th><th>You owner?</th></tr>
        </thead>
        <tbody>
            <?php
                $content = new Models_Anonces();
                $anonces  = $content->getAllAnonces();
                $user = new Models_User();
                $owner = $user->getOwner('anonce', $_COOKIE['user_id']);
                $mark = '';
                foreach ($anonces as $anonce)
                {
                    foreach ($owner as $value)
                    {
                        if($value['id'] == $anonce['id'])
                        {
                            $mark = '+';
                            break;
                        } else {
                            $mark = '';
                        }
                    }
                    ?>
                        <tr><td><?php echo $anonce['id']; ?></td><td><?php echo $anonce['title']; ?></td><td><i class="icon-calendar"></i> <?php echo $anonce['modified']; ?></td><td>
                                <a class="btn btn-primary btn-mini" href="/<?php $content->printPath(); ?>articles/editanonce/<?php echo $anonce['id']; ?>"><i class="icon-pencil icon-white"></i></a>
                                <a class="btn btn-danger btn-mini" href="/"><i class="icon-remove icon-white"></i></a>
                            </td><td><?php echo $mark; ?></td></tr>
                     <?php
                }
            ?>
        </tbody>
     </table>
</div>